#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 6;
int T, n, m, L, V, d[N], ans, close;
struct car{
    int start, v0, add;
}a[N];
set<int> b;
int main(){

	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);

    cin >> T;
    for(int i = 1; i <= T; i++){
        cin >> n >> m >> L >> V;
        for(int j = 1; j <= n; j++){
            cin >> a[j].start >> a[j].v0 >> a[j].add;
            b.insert(a[j].start);
        }
        memset(d, 0, sizeof(d));
        for(int j = 1; j <= m; j++){
            cin >> d[j];
        }
        ans = close = 0;
        if(a[1].add == 0){
            for(int j = 1; j <= n; j++){
                if(a[j].v0 > V && d[m] >= a[j].start) ans++;
                else b.erase(a[j].start);
            }
            if(ans == 0){
                cout << 0 << " " << m << endl;
                continue;
            }
            int res = 1;
            while(d[res] <= *b.begin()) res++, close++;
            res = m;
            for(int j = m; j >= 1; j--){
                while(d[res] >= *b.begin() + j) res--, close++;
            }
            cout << ans << " " << close - 1 << endl;
        }
        else if(a[i].add > 0){
            for(int j = 1; j <= n; j++){
                if(a[j].v0 > V){
                    ans++;
                    continue;
                }
                double lim = 1.0 * (V * V - a[j].v0 * a[j].v0) / (2.0 * a[j].add);
                if(d[m] > a[j].start + lim) ans++;
            }
            cout << ans << endl;
        }
    }
	return 0;
}
